package org.javabasics.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;

/**
 * Created by LUOLIANG on 2016/9/21.
 * 字符输入流
 */
public class FileReaderTest {
    public static void main(String[] args) {
        String name = URLDecoder.decode(
                System.getProperty("user.dir") + "/basicsPractice/src/org/javabasics/io/FileReaderTest.java");
        try (FileReader fr = new FileReader(name)) {
            char[] cbuf = new char[32];
            int hasRead = 0;
            while ((hasRead = fr.read(cbuf)) > 0) {
                System.out.println(new String(cbuf, 0, hasRead));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
